$(function() {
    var download = $('#download_album');
    $("#main_container").css('min-height',window_height);
    /*---------------------------点击其它区域隐藏下载提醒-------------------------*/
    $(document).on('click',function(){
        if($("#download_tips_block").css("display")=="block"){
            $("#download_tips_block").css("display","none");
        }
    });
    /*---------------------------点击其它区域隐藏下载提醒-------------------------*/

    //初始化下载提醒块
    var body_width = $('body').width();
    $("#download_tips_block").css({
        "display":"none",
        "width":window_width,
        "height":'100%',
        "z-index":1000
    });

    $('#download_tips_block img').css({
        "width":body_width,
        "display":"none",
        "height":body_width*(536/480),
        "position":"absolute",
        "z-index":99999
    });

    /*------------------------------下载提醒块-----------------------------------*/
    download.on("click",DownloadTipsPop);
    /*------------------------------下载提醒块-----------------------------------*/

    $("#download_tips_block").bind("click",function(){
        $("#download_tips_block").css("display","none");
    });

    /*------------------------------下载提醒块-----------------------------------*/


    /*---------------------------点击页面隐藏企业pop--------------------------*/
    $('#main_container').on('click',function(){
        $('#einfo_pop').slideUp(300);
    });
    /*---------------------------点击页面隐藏企业pop--------------------------*/

    /*---------------------------推广弹出层------------------------------*/
    $("#adBtn").bind("click",function(e){
        e.stopPropagation();
        $('#adModal').modal('show');
    });
    /*---------------------------推广弹出层------------------------------*/

    //画册有密码
    if(parseInt(isAlbumLocked)==1 && parseInt(isAlbumUnLocked)==0){
        $('#download_album').on('click',InputAlbumPassword);
        $('#download_album').unbind('click',DownloadTipsPop);
    }

    //提交画册密码操作
    $('#submit_albumPassword').on('click',VerifyAlbumPassword);

});

/*-------------------------------------------------方法---------------------------------------------------*/
//提交验证画册密码
function VerifyAlbumPassword(e){
    var alias = $('#alias').val();
    var i_albumPassword = $('#i_albumPassword').val();
    if(i_albumPassword==""){
        alert('请输入画册密码再提交！');
        return false;
    }
    $.ajax({
        type: "POST",
        url: mw_site_url+"/index/verifyAlbumPassword",
        data:"i_albumPassword="+i_albumPassword+"&alias="+alias,
        dataType:"json",
        beforeSend:function(){
            $(e.target).html('请等待...');
            $(e.target).attr('disabled','disabled');
        },
        success: function(data){
            $(e.target).html('提交修改');
            $(e.target).removeAttr('disabled');
            switch(parseInt(data)){
                case 0:
                    alert('密码错误！');
                    break;
                case -1:
                    alert('系统错误！');
                    break;
                default:
                    alert('密码正确，请重新点击下载按钮！');
                    $('#responsive').modal('hide');
                    $('#download_album').unbind('click',InputAlbumPassword);
                    $("#download_album").bind("click",DownloadTipsPop);
                    var download = $("#download_album");
                    var os = $("#operation_system").val();
                    download.attr("href", data.appDownloadUrl);
                    break;
            }
        }
    });
}

//点击下载弹出画册密码输入框
function InputAlbumPassword(){
    $('#i_albumPassword').val('');
    $('#responsive').modal();
}

//下载提醒块
function DownloadTipsPop(e){
    var scrollTop=0;
    if(document.documentElement&&document.documentElement.scrollTop)
    {
        scrollTop=document.documentElement.scrollTop;
    }
    else if(document.body)
    {
        scrollTop=document.body.scrollTop;
    }
    e.stopPropagation();
    if(parseInt(is_MMBroswer)>0){
        if($("#download_tips_block").css("display")=="none"){
            $("#download_tips_block").css('display','block');
            $("#download_tips_block img").css('top',0);
            $('#download_tips_block img').css("display",'block');
        }
        else if($("#download_tips_block").css("display")=="block"){
            $("#download_tips_block").css("display","none");
            $('#download_tips_block img').css("display",'none');
        }
        if($('.bottomNavDiv').css('display')=="block"){
            $('.bottomNavDiv').slideUp(300);
            $('.top').slideUp(300);
        }
        else{
            $('.bottomNavDiv').slideDown(300);
            $('.top').slideDown(300);
        }
    }
}

//点击底部企业信息弹出pop
function einfo_pop(){
    if($('#einfo_pop').is(':hidden')){
        $('#einfo_pop').slideDown(300);
    }else{
        $('#einfo_pop').slideUp(300);
    }
}

